
var index = 1,
	banner = document.getElementById('banner'),
	img = banner.children[0],
	ss = banner.children[1].children;
var no;

// 创建轮播函数
function playImg(){
	clearInterval(no);
	no = setInterval(function(){
		index++;
		if(index>3){
			index=1;
		}
		img.src="images/"+index+".jpg";
		changeBgColor(index-1);
	},1000);
}
// 创建轮播同时改变编号颜色函数
function changeBgColor(suoyin){
	for(var a = 0;a<ss.length;a++){
		ss[a].style.backgroundColor = "#e4e2e0";
	}
	ss[suoyin].style.backgroundColor = "#333";
}
for(var i = 0;i<ss.length;i++){
	ss[i].ind = i;
	ss[i].onmouseover = function(){
		clearInterval(no);
		index = this.ind+1;
		img.src = "images/"+index+".jpg";
		changeBgColor(this.ind);
	}
	ss[i].onmouseout = function(){
		playImg();
	}
}
playImg();


// 点击地图模式出现遮罩，并出现地图
var map = document.getElementsByClassName('map')[0],
	shadow = document.getElementById('shadow'),
	mapDiv = document.getElementById('mapDiv'),
	quit = document.getElementsByClassName('mapTop')[0].children[1];
map.onclick = function (){
	mapDiv.style.display = "block";
	shadow.style.display = "block";
}
// 点击地图右上角退出
quit.onclick = function () {
	mapDiv.style.display = "none";
	shadow.style.display = "none";
}



// mainBottom的部分
// 点击北京和选择区县出现相应的div选项
var city = $(".one"),
	citys = $("#city"),
	quXian = $(".two"),
	quXians = $("#quxian"),
	close = $("#close"),
	close2 = $("#close2");
// 点击城市出现城市列表
city.on("click" , function(){
	citys.show();
});
// 点击区县出现区县列表
quXian.on("click" , function(){
	quXians.show();
});
// 点击城市列表中的关闭，关闭城市列表
citys.on("click" ,"#close", function(e){
	citys.hide();
	e.stopPropagation();
});
// 点击区县里列表中的关闭，关闭区县列表
close2.on("click",function(e){
	quXians.hide();
	e.stopPropagation();
})




// 头部点击“切换城市”，出现城市列表div
var cityA = $("#cityA"),
	allCity = $(".qiehuanchengshi");

cityA.on("click" , function(){
	allCity.show();
});
allCity.on("click" , "input" , function(){
	allCity.hide();
})

$("#zhucezhuce").on("click",  function(){
	$(".zhuce").show();
});
$(".guanGuan").on("click",  function(){
	$(".zhuce").hide();
});